package com.qhgrain.api.menurolepermission.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.pubframework.springmybatis.dao.IMysqlBaseMapper;
import com.qhgrain.api.menurolepermission.entity.RolePermission;

public interface RolePermissionMapper extends IMysqlBaseMapper<RolePermission>{

	void insertBatch(List<RolePermission> list);
	
	void deleteByUpate(@Param("roleId")String roleId,@Param("permissionIds")List<String> permissionIds);
	
	@Delete("delete from base_role_permission where  role_id=#{roleId} ")
	void deleteByRoleId(@Param("roleId")String roleId);
	
	void deleteBatch(@Param("roleId")String roleId,@Param("permissionIds")List<String> permissionIds);
	@Select("select rp.id,rp.role_id as 'roleId',rp.permission_id as 'permissionId' "
			+ " from base_role_permission rp"
			+ " join base_permission p on rp.permission_id = p.id"
			+ " join base_menu m on p.menu_id = m.id "
			+ " where rp.role_id = #{roleId} "
			+ " and m.app_id=#{appId} "
			+ " and m.status = 0 ")
	List<RolePermission> queryByRoleId(@Param("roleId")String roleId,@Param("appId")String appId);
}
